import static org.junit.Assert.*;

import java.util.Iterator;

import org.junit.Before;
import org.junit.Test;


public class PowerGridTest {

	PowerGridTest my_test_grid;
	
	@Before
	public void setUp() throws Exception {
		my_test_grid = new PowerGridTest();
	}

	@SuppressWarnings("deprecation")
	@Test
	public void testGetMinimumSpanningTree() {
		SimpleGraph my_test_graph = new SimpleGraph();
		Vertex a, b, c, d, e;
        Edge a_to_b, a_to_c, a_to_d,
        b_to_d, c_to_d, e_to_c, d_to_e;
        
        a = my_test_graph.insertVertex(null, "A");
        b = my_test_graph.insertVertex(null, "B");
        c = my_test_graph.insertVertex(null, "C");
        d = my_test_graph.insertVertex(null, "D");
        e = my_test_graph.insertVertex(null, "E");
        
        a_to_b = my_test_graph.insertEdge(a, b, (double) 2, "a to b");
        a_to_c = my_test_graph.insertEdge(a, c, (double) 3, "a to c");
        a_to_d = my_test_graph.insertEdge(a, d, (double) 10, "a to d");
        b_to_d = my_test_graph.insertEdge(b, d, (double) 1, "b to d");
        c_to_d = my_test_graph.insertEdge(c, d, (double) 2, "c to d");
        e_to_c = my_test_graph.insertEdge(e, c, (double) 1, "e to c");
        d_to_e = my_test_graph.insertEdge(d, e, (double) 5, "d to e");
        
        double the_graph_weight = PowerGrid.getMinimumSpanningTree(my_test_graph, new SimpleGraph());
        
        assertEquals(the_graph_weight,6, 1);
//        
//        Iterator i;
//        Vertex v;
//        Edge E;
//        
//        System.out.println("Iterating through vertices...");
//        for (i= my_test_graph.vertices(); i.hasNext(); ) {
//            v = (Vertex) i.next();
//            System.out.println("found vertex " + v.getName());
//        }
//
//        System.out.println("Iterating through adjacency lists...");
//        for (i= my_test_graph.vertices(); i.hasNext(); ) {
//            v = (Vertex) i.next();
//            System.out.println("Vertex "+v.getName());
//            Iterator j;
//            
//            for (j = my_test_graph.incidentEdges(v); j.hasNext();) {
//                E = (Edge) j.next();
//                System.out.println("  found edge " + E.getName());
//                System.out.println("  weight is " + E.getData());
//            }
//        }
		

	} //end of testGetMinimumSpanningTree()

}
